package cn.rkylin.oms.salespromotion.rules.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageInfo;

import cn.rkylin.oms.order.vo.OrderVO;
import cn.rkylin.oms.salespromotion.rules.vo.SalesPromotionRuleVO;

/**
 * 促销规则管理模块服务层接口
 * @author zhanghao
 *
 */
public interface ISalesPromotionRuleService {
    /**
     * 获取规则列表的分页查询结果
     * @param page 页数
     * @param rows  行数
     * @param ruleVO    规则查询对象
     * @return 分页结果
     * @throws Exception
     */
    public PageInfo<SalesPromotionRuleVO> findRuleList(int page, int rows, SalesPromotionRuleVO ruleVO) throws Exception;
    
    /**
     * 根据规则ID查询规则详情
     * @param ruleId 规则ID
     * @return
     */
    public SalesPromotionRuleVO findRuleById(String ruleId);
    
    /**
     * 启用规则
     * @param ruleId
     * @return
     */
    public int enableRuleState(String ruleId);
    
    /**
     * 禁用规则
     * @param ruleId
     * @return
     */
    public int disableRuleState(String ruleId);
    
    /**
     * 根据规则ID删除规则
     * @param ruleId
     * @return
     */
    public int deleteRule(String ruleId);
    
    /**
     * 新增规则
     * @param ruleVO
     * @return
     */
    public SalesPromotionRuleVO insertRule(SalesPromotionRuleVO ruleVO);
    /**
     * 更新规则
     * @param ruleVO
     * @return
     */
    public SalesPromotionRuleVO updateRule(SalesPromotionRuleVO ruleVO);
    
    /**
     * 复制规则
     * @param originRuleId
     * @return 新的规则对象
     */
    public SalesPromotionRuleVO insertRuleByOriginRuleId(String originRuleId);
    
    /**
     * generateGiftList:输入订单并根据已有的校验规则，获取赠品列表. <br/>
     *
     * @author zhanghao
     * @param orderVO
     * @return map<规则ID，系统商品（有赠品标识）对象>
     * @throws Exception 
     */
    public Map<String,Object> generateGiftList(OrderVO orderVO) throws Exception;

    /**
     * 获取各状态的规则的数值
     * @param queryParamVO 
     * @return
     * @throws Exception 
     */
    @SuppressWarnings("rawtypes")
    List<HashMap> findStateCount(SalesPromotionRuleVO queryParamVO) throws Exception;

    /**
     * duplicatedValid:校验规则重复. <br/>
     *
     * @author zhanghao
     * @param ruleVO
     * @return
     * @throws Exception
     */
    boolean duplicatedValid(SalesPromotionRuleVO ruleVO) throws Exception;
}
